package com.game;

import java.awt.*;

public abstract class GameObject {

    //游戏元素图片
    private Image img;
    //游戏元素的横纵坐标
    int x;
    int y;
    //引入主界面
    private GamePanel gamePanel;

    public GameObject(String img, int x, int y, GamePanel gamePanel) {
        this.img = Toolkit.getDefaultToolkit().getImage(img);
        this.x = x;
        this.y = y;
        this.gamePanel = gamePanel;
    }
    //绘制方法
    public abstract void paintSelf(Graphics g);

    //返回自身矩形（检测碰撞）
    public abstract Rectangle gerRec();


    public Image getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = Toolkit.getDefaultToolkit().getImage(img);
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public GamePanel getGamePanel() {
        return gamePanel;
    }

    public void setGamePanel(GamePanel gamePanel) {
        this.gamePanel = gamePanel;
    }

}